<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta content='width=device-width, initial-scale=1.0' name='viewport'>
    <meta content='' name='description'>
    <meta content='Nils Nordman' name='author'>
    <link href='/images/howl.png' rel='shortcut icon'>
    <title>Howl :: Spec - howl.ui.Cursor</title>
    <link href="/stylesheets/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/syntax.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/howl.css" media="screen" rel="stylesheet" type="text/css" />
    <script src="https://code.jquery.com/jquery-1.12.3.min.js" type="text/javascript"></script>
    <script src="/javascripts/bootstrap.min.js" type="text/javascript"></script>
    
    <link href='//fonts.googleapis.com/css?family=Josefin+Slab' rel='stylesheet' type='text/css'>
    <link href='//fonts.googleapis.com/css?family=Open+Sans+Condensed:700' rel='stylesheet' type='text/css'>
  </head>
  <body class='doc doc_spec doc_spec_ui doc_spec_ui_cursor_spec'>
    <div class='container'>
      <div class='masthead'>
        <ul class='nav nav-pills'>
          <li>
            <a href='/'>
              <span class='glyphicon glyphicon-home'></span>
              Home
            </a>
          </li>
          <li>
            <a href='/doc/'>
              <span class='glyphicon glyphicon-book'></span>
              Documentation
            </a>
          </li>
          <li>
            <a href='/blog/'>
              <span class='glyphicon glyphicon-bullhorn'></span>
              Blog
            </a>
          </li>
          <li>
            <a href='/contact.html'>
              <span class='glyphicon glyphicon-inbox'></span>
              Contact
            </a>
          </li>
        </ul>
      </div>
      <ol class="breadcrumb"><li><a href="/">Home</a></li><li><a href='../../'>Howl Documentation (master branch)</a></li><li>Spec</li><li>Ui</li><li>Spec - howl.ui.Cursor</li></ol>
      <div class="spec-group spec-group-1">&#x000A;&#x000A;<h1 id="howl.ui.cursor">howl.ui.Cursor</h1>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Editor</span><span class="w"> </span><span class="n">buffer</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">cursor</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">selection</span><span class="w">&#x000A;</span><span class="n">window</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Gtk</span><span class="p">.</span><span class="nc">OffscreenWindow</span><span class="w"> </span><span class="ss">default_width:</span><span class="w"> </span><span class="mi">800</span><span class="p">,</span><span class="w"> </span><span class="ss">default_height:</span><span class="w"> </span><span class="mi">640</span><span class="w">&#x000A;</span><span class="n">window</span><span class="o">\</span><span class="n">add</span><span class="w"> </span><span class="n">editor</span><span class="o">\</span><span class="n">to_gobject</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">window</span><span class="o">\</span><span class="n">show_all</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">pump_mainloop</span><span class="o">!</span><span class="w">&#x000A;&#x000A;</span><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;  </span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span></pre>&#x000A;&#x000A;<h4 id=".at_end_of_line-returns-true-if-cursor-is-at-the-end-of-the-line">.at_end_of_line returns true if cursor is at the end of the line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_false</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_end_of_line</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_end_of_line</span></pre>&#x000A;&#x000A;<h4 id=".at_start_of_line-returns-true-if-cursor-is-at-the-start-of-the-line">.at_start_of_line returns true if cursor is at the start of the line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_start_of_line</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_false</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_start_of_line</span></pre>&#x000A;&#x000A;<h4 id=".at_end_of_file-returns-true-if-cursor-is-at-the-end-of-the-buffer">.at_end_of_file returns true if cursor is at the end of the buffer</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_false</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_end_of_file</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">eof</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_end_of_file</span></pre>&#x000A;&#x000A;<h4 id="down()-moves-the-cursor-one-line-down,-respecting-the-current-column">down() moves the cursor one line down, respecting the current column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello\nmy\nworld'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">down</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">down</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span></pre>&#x000A;&#x000A;<h4 id="up()-moves-the-cursor-one-line-up,-respecting-the-current-column">up() moves the cursor one line up, respecting the current column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">up</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span></pre>&#x000A;&#x000A;<h4 id="right()-moves-the-cursor-one-char-right">right() moves the cursor one char right</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span></pre>&#x000A;&#x000A;<h4 id="left()-moves-the-cursor-one-char-left">left() moves the cursor one char left</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span></pre>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".style">.style</h2>&#x000A;&#x000A;<h4 id="is-&quot;line&quot;-by-default">is &quot;line&quot; by default</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'line'</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">style</span></pre>&#x000A;&#x000A;<h4 id="raises-an-error-if-set-to-anything-else-than-&quot;block&quot;-or-&quot;line&quot;">raises an error if set to anything else than &quot;block&quot; or &quot;line&quot;</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">cursor</span><span class="p">.</span><span class="n">style</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'block'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">style</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'line'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">raises</span><span class="w"> </span><span class="s1">'foo'</span><span class="p">,</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">style</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'foo'</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".pos">.pos</h2>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt'</span></pre>&#x000A;&#x000A;<h4 id="reading-returns-the-current-character-position-in-one-based-index">reading returns the current character position in one based index</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">editor</span><span class="p">.</span><span class="n">view</span><span class="p">.</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w"> </span><span class="c1">-- raw aullar access, really at 'e'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="setting-sets-the-current-position">setting sets the current position</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span></pre>&#x000A;&#x000A;<h4 id="setting-adjusts-the-selection-if-it-is-persistent">setting adjusts the selection if it is persistent</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span></pre>&#x000A;&#x000A;<h4 id="out-of-bounds-values-are-automatically-corrected">out-of-bounds values are automatically corrected</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">math.huge</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="o">#</span><span class="n">buffer</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">#</span><span class="n">buffer</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="o">#</span><span class="n">buffer</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".line">.line</h2>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="sh">[[&#x000A;Liñe 1 ʘf tƏxt&#x000A;And hƏre's line twʘ&#x000A;]]</span></pre>&#x000A;&#x000A;<h4 id="returns-the-current-line">returns the current line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span></pre>&#x000A;&#x000A;<h4 id="setting-moves-the-cursor-to-the-first-column-of-the-specified-line">setting moves the cursor to the first column of the specified line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span></pre>&#x000A;&#x000A;<h4 id="assignment-adjusts-out-of-bounds-values-automatically">assignment adjusts out-of-bounds values automatically</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">100</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="o">#</span><span class="n">buffer</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="assignment-adjusts-the-selection-if-it-is-persistent">assignment adjusts the selection if it is persistent</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt\n'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".column">.column</h2>&#x000A;&#x000A;<h4 id="returns-the-current-column">returns the current column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span></pre>&#x000A;&#x000A;<h4 id="takes-tabs-into-account">takes tabs into account</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\tsome text after'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".column-=-&lt;nr&gt;">.column = &lt;nr&gt;</h2>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-specified-column">moves the cursor to the specified column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="takes-tabs-into-account">takes tabs into account</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\tsome text after'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="adjusts-the-selection-if-it-is-persistent">adjusts the selection if it is persistent</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".column_index">.column_index</h2>&#x000A;&#x000A;<h4 id="returns-the-real-column-index-for-the-current-line-disregarding-tabs">returns the real column index for the current line disregarding tabs</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\tsome text'</span><span class="w">&#x000A;  </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;  </span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span></pre>&#x000A;&#x000A;<h4 id="returns-the-column-index-as-a-character-offset">returns the column index as a character offset</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö\nåäö'</span><span class="w">&#x000A;  </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">6</span><span class="w">&#x000A;  </span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".column_index-=-&lt;nr&gt;">.column_index = &lt;nr&gt;</h2>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\tsome text after'</span></pre>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-specified-column-index">moves the cursor to the specified column index</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span></pre>&#x000A;&#x000A;<h4 id="treats-&lt;nr&gt;-as-a-character-offset">treats &lt;nr&gt; as a character offset</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö\nåäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span></pre>&#x000A;&#x000A;<h4 id="adjusts-the-selection-if-it-is-persistent">adjusts the selection if it is persistent</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'åä'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="move_to">move_to<span class="arg-list">(opts = {})</span></h2>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-specified-line-and-column-if-given">moves the cursor to the specified line and column if given</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello\nworld'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="ss">line:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">column:</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="ss">line:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="ss">column:</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-specified-pos-if-given">moves the cursor to the specified pos if given</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="ss">pos:</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="extends-the-selection-if-the-&lt;extend&gt;-option-is-truthy">extends the selection if the &lt;extend&gt; option is truthy</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello\nworld'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="ss">line:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">column:</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="ss">extend:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'he'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="ss">pos:</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="ss">extend:</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hello\nw'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span></pre>&#x000A;&#x000A;<h4 id="considers-&lt;column&gt;-to-be-a-virtual-column">considers &lt;column&gt; to be a virtual column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\t23'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="ss">line:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">column:</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="accepts-&lt;column_index&gt;-as-well,-considering-that-a-real-column">accepts &lt;column_index&gt; as well, considering that a real column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\t23'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="ss">line:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="ss">column_index:</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="word_right">word_right</h2>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-start-of-the-following-word">moves the cursor to the start of the following word</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12 xy 78'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-punctuation">handles punctuation</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'foo.bar'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-tabs-properly">handles tabs properly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\t\tfoo_bar\txy'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="c1">-- 'f'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">11</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="moves-to-the-end-of-the-line-if-no-further-word-is-available">moves to the end of the line if no further word is available</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'{\n34'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'xy\n45'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n45'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-unicode-properly">handles unicode properly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'LinƏ !!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id="when-at-the-end-of-the-line">when at the end of the line</h3>&#x000A;&#x000A;<h4 id="moves-to-the-first-non-blank-on-the-next-line">moves to the first non-blank on the next line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'123\n  78'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'123\n56'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="does-nothing-if-at-the-end-of-file">does nothing if at the end of file</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'123'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="leaves-the-cursor-at-end-of-file-if-no-next-word-is-present">leaves the cursor at end of file if no next word is present</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'123'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="word_right_end">word_right_end</h2>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-end-of-the-current-word">moves the cursor to the end of the current word</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'foo bar 56 !'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- after 'foo'</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- after 'bar'</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">11</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- after '56'</span></pre>&#x000A;&#x000A;<h4 id="handles-punctuation">handles punctuation</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'foo.bar'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- '.'</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-unicode-properly">handles unicode properly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'LinƏ !!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-single-stand-alone-punctuation">handles single stand-alone punctuation</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">' { foo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-tabs-properly">handles tabs properly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\t\tfoo_bar\txy'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w"> </span><span class="c1">-- 'f'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">10</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id="when-at-the-end-of-the-line">when at the end of the line</h3>&#x000A;&#x000A;<h4 id="moves-to-the-first-non-blank-on-the-next-line">moves to the first non-blank on the next line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'123\n  78'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">9</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'123\n56'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="does-nothing-if-at-the-end-of-file">does nothing if at the end of file</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'123'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="leaves-the-cursor-at-end-of-file-if-no-next-word-is-present">leaves the cursor at end of file if no next word is present</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12  '</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_right_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="word_left">word_left</h2>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-start-of-the-following-word">moves the cursor to the start of the following word</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'a b 12 0x !!'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">12</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">11</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- first '!'</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- '0'</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-punctuation">handles punctuation</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'(foo .bar'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">10</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-unicode-properly">handles unicode properly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'LinƏ åäö '</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">10</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-numbers-">handles numbers </h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">' x 2 '</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-tabs-properly">handles tabs properly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\t\tfoo_bar\txy'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when no further word is available)</span></h3>&#x000A;&#x000A;<h4 id="moves-to-the-end-of-the-previous-line">moves to the end of the previous line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n45'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n 56'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'xy\nz'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="does-nothing-if-at-the-start-of-file">does nothing if at the start of file</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'123'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="moves-to-the-start-of-the-file-if-no-previous-line-is-available">moves to the start of the file if no previous line is available</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'  34'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="word_left_end">word_left_end</h2>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-end-of-the-previous-word">moves the cursor to the end of the previous word</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'foo bar 56 !'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">13</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">11</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- end of '56'</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- end of 'bar'</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- end of 'foo'</span></pre>&#x000A;&#x000A;<h4 id="handles-punctuation">handles punctuation</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'foo.bar'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">8</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- after '.'</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="c1">-- after 'foo'</span></pre>&#x000A;&#x000A;<h4 id="handles-single-stand-alone-punctuation">handles single stand-alone punctuation</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">' { foo'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">7</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-unicode-properly">handles unicode properly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'LiñƏ åäö x'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">10</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">9</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-tabs-properly">handles tabs properly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'foo\tbar'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when no further word is available)</span></h3>&#x000A;&#x000A;<h4 id="moves-to-the-end-of-the-previous-line">moves to the end of the previous line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n45'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n 56'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'xy\nz'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="does-nothing-if-at-the-start-of-file">does nothing if at the start of file</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'123'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="moves-to-the-start-of-the-file-if-no-previous-line-is-available">moves to the start of the file if no previous line is available</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'  34'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">word_left_end</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="para_up">para_up</h2>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when between paragraphs)</span></h3>&#x000A;&#x000A;<h4 id="moves-to-the-first-previous-blank-line-before-the-above-paragraph">moves to the first previous blank line before the above paragraph</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n\n5\n7\n'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">9</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">para_up</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span></pre>&#x000A;&#x000A;<h4 id="moves-to-the-start-of-the-buffer-if-no-previous-paragraph-exists">moves to the start of the buffer if no previous paragraph exists</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n\n'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">para_up</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when in the middle of a paragraph)</span></h3>&#x000A;&#x000A;<h4 id="moves-to-the-first-previous-blank-line">moves to the first previous blank line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n\n56\n89'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">9</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">para_up</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span></pre>&#x000A;&#x000A;<h4 id="moves-to-the-start-of-the-buffer-if-no-previous-paragraph-exists">moves to the start of the buffer if no previous paragraph exists</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n45'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">para_up</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="para_down">para_down</h2>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when between paragraphs)</span></h3>&#x000A;&#x000A;<h4 id="moves-to-the-next-blank-line-after-the-above-paragraph">moves to the next blank line after the above paragraph</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n\n5\n7\n'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">para_down</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span></pre>&#x000A;&#x000A;<h4 id="moves-to-the-end-of-the-buffer-if-no-subsequent-paragraph-exists">moves to the end of the buffer if no subsequent paragraph exists</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n\n5'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">para_down</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-3">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when in the middle of a paragraph)</span></h3>&#x000A;&#x000A;<h4 id="moves-to-the-next-blank-line">moves to the next blank line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n45\n\n89'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">para_down</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span></pre>&#x000A;&#x000A;<h4 id="moves-to-the-end-of-the-buffer-if-no-subsequent-paragraph-exists">moves to the end of the buffer if no subsequent paragraph exists</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'12\n45'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">para_down</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="home_indent">home_indent</h2>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-first-non-blank-column">moves the cursor to the first non-blank column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'  345'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">home_indent</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="does-nothing-for-an-empty-line">does nothing for an empty line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\nsecond'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">home_indent</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;&#x000A;<h4 id="handles-tabs-correctly">handles tabs correctly</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\t 345'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">home_indent</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id="home_indent_auto">home_indent_auto</h2>&#x000A;&#x000A;<h4 id="toggles-the-cursor-between-the-first-and-the-first-non-blank-column">toggles the cursor between the first and the first non-blank column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'  345'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">home_indent_auto</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">home_indent_auto</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">home_indent_auto</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when passing true for extended_selection to movement commands)</span></h3>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="sh">[[&#x000A;Liñe 1 ʘf tƏxt&#x000A;And hƏre's line twʘ&#x000A;]]</span></pre>&#x000A;&#x000A;<h4 id="the-selection-is-extended-along-with-moving-the-cursor">the selection is extended along with moving the cursor</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">sel</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">selection</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">right</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'L'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">down</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt\nA'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">left</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt\n'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">up</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">empty</span></pre>&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when the editor selection is marked as persistent)</span></h3>&#x000A;&#x000A;<h4 id="the-selection-is-extended-along-with-moving-the-cursor">the selection is extended along with moving the cursor</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><span class="n">sel</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">selection</span><span class="w">&#x000A;</span><span class="n">sel</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'L'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt\nA'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span></pre>&#x000A;</div>&#x000A;</div>
      <div class='footer text-muted'>
        <a href='/'>
          <img width="50" height="50" class="footer-logo" src="/images/howl.png" />
        </a>
        <div class='footer-follow'>
          <p>
            <a class='twitter-follow-button' data-lang='en' data-show-count='false' href='https://twitter.com/howleditor' rel='me'>
              Follow @howleditor
            </a>
          </p>
          <p>
            <a class='twitter-share-button' data-count='none' data-hashtags='howleditor' data-lang='en' data-text='The Howl Editor, a general purpose, light-weight customizable editor.' data-url='http://howl.io' href='https://twitter.com/share'>
              Tweet
            </a>
          </p>
        </div>
        <div class='footer-blurb'>
          <div>The Howl editor.</div>
          <div>
            Copyright 2012-2016
            <a class='alert-link' href='https://github.com/howl-editor/howl/contributors'>
              The Howl Developers.
            </a>
          </div>
        </div>
      </div>
    </div>
    <script>
      <!-- / GA -->
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-45283282-1', 'howl.io');
      ga('send', 'pageview');
      <!-- / Twitter -->
      !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
      if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
      js.src="//platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
  </body>
</html>
